home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / super_su.swf / scripts / DefineSprite_33_obstaculo_07 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-04-19  |  1.1 KB  |  52 lines

  1. function mKill()
  2. {
  3.    this._parent.mKillObject(this);
  4. }
  5. function mPhysics(interval)
  6. {
  7.    var newPosX = this.intPosX + this.intVelX * interval;
  8.    var newPosY = this.intPosY + this.intVelY * interval;
  9.    this.intPosX = newPosX;
  10.    this.intPosY = newPosY;
  11. }
  12. function mStepFrame(interval)
  13. {
  14.    this.mPhysics(interval);
  15.    if(this.intRadius < 1)
  16.    {
  17.       this.intRadius = 20;
  18.    }
  19.    if(this.strID.length < 1)
  20.    {
  21.       this.strID = "obst";
  22.    }
  23.    var oChar = this._parent.oChar;
  24.    var dX = Math.abs(oChar.intPosX - this.intPosX);
  25.    if(dX < 200)
  26.    {
  27.       var arrPnts = oChar.mGetPoints();
  28.       var hit = false;
  29.       var i = 0;
  30.       while(i < arrPnts.length)
  31.       {
  32.          var dX = this.intPosX - arrPnts[i].x;
  33.          var dY = this.intPosY - arrPnts[i].y;
  34.          var dAbs = Math.abs(Math.sqrt(dX * dX + dY * dY));
  35.          if(dAbs < this.intRadius)
  36.          {
  37.             var hit = true;
  38.          }
  39.          i++;
  40.       }
  41.       if(hit)
  42.       {
  43.          oChar.mCollide(this.strID);
  44.       }
  45.    }
  46.    if(oChar.intPosX - this.intPosX > 500)
  47.    {
  48.       this.mKill();
  49.    }
  50. }
  51. this.intRadius = 10;
  52.